% this is a main process to do the strategies selection baseon on multi-factor model

%% get factor values of each strategy across the period
%   Detailed explanation goes here
periodLength=1000;

% load strats group' fake data
stratsGroup=fakeStrategyPool(periodLength);

% calculate factor value and save them
factorValueFile=FVCalculator(stratsGroup);
factorValueSaver('D:\matlab workspace\multi-factor strategies selection framework\Data\factorValueTable.xlsx',factorValueFile);
disp('go into factor rank process')


%% analysis multi-factor model
% for each factor : do rank
factorNum=size(factorValueFile,1);
for i=1:factorNum 
   oneFactorData=squeeze( factorValueFile(i,:,:));
   % 1.group by factor value's rank
   [rankedFactorValue,index]=sort(oneFactorData);
   % 2. get each group's portfolio expected return with name:
   % top20,top40,top60,top80,top100
   
   rankGroupNum=5;
   rankGroupLength=periodLength-100;
   rankGroupData=zeros(rankGroupNum,rankGroupLength);
   for m=1:rankGroupNum
       for n =1:rankGroupLength
           rankGroupData(m,n)=loadGroupData(stratsGroup,index,rankGroupLength,rankGroupNum,m,n);
       end
   end
   
   plot(rankGroupData);
   
   
   
   
   % 3.

end




